package teach.shuji.java12.system.controller;


import cn.dev33.satoken.stp.StpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import teach.shuji.java12.common.CommonResult;
import teach.shuji.java12.system.dto.DepartmentSelectParam;
import teach.shuji.java12.system.dto.departments.DepartmentAddParam;
import teach.shuji.java12.system.entity.Department;
import teach.shuji.java12.system.service.DepartmentService;

import java.util.List;

@Controller
@RequestMapping("dpt")
@RestController
public class DepartmentController {

    @Autowired
    DepartmentService departmentService;

//    @PostMapping("list")
//    public List<Department> list(@RequestBody(required=false) DepartmentSelectParam param)
//    {
//        return departmentService.Select(param);
//    }
//
//    @GetMapping("get")
//    public Department get(long id){
//        return departmentService.getById(id);
//    }

    @PostMapping("insert")
    public CommonResult<Long> insert(@RequestBody @Validated DepartmentAddParam param)
    {
        StpUtil.checkLogin();
        return departmentService.insert(param);
    }
//
//    @PutMapping("update")
//    public void update(@RequestBody Department dpt)
//    {
//        departmentService.Update(dpt);
//    }
//
//    @DeleteMapping("delete")
//    public void delete(long id)
//    {
//        departmentService.Delete(id);
//    }
}
